package com.orange.core.mapper.product;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.orange.core.pojo.entity.product.CreditProduct;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface CreditProductMapper extends BaseMapper<CreditProduct> {

    @Update("update credit_product set stock = stock - #{stock} where id = #{productId} and stock >= #{stock}")
    boolean deductStock(@Param("productId") Integer productId, @Param("stock") Integer stock);
}
